﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Shader01Controller : MonoBehaviour
{

    public float fade = 1f;

    Material mat;
    bool isDissolving;

    void Start()
    {
        mat = GetComponent<SpriteRenderer>().material;
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            isDissolving = true;
        }
        if (isDissolving)
        {
            fade -= Time.deltaTime;
            if (fade <= 0)
            {
                fade = 0f;
                isDissolving = false;
            }
            mat.SetFloat("_Fade", fade);
        }
    }
}
